{{include file="../Common/head.html"}}
    <div class="container" style="margin-top: 20px">
        <div class="alert alert-success" role="alert">
            <!--<h2 style="display: inline-block;line-height: 100%">学生管理</h2>-->
            <button class="button button-royal button-pill button-giant"><h2 style="display: inline-block;line-height: 100%">学生管理系统</h2></button>
            <a href="index.php?m=Admin" class="button button-3d button-caution" style="float: right;margin-top: 10px">返回班级管理</a>
        </div>
        <button type="button" data-toggle="modal" data-target="#myModal" class="button button-3d button-action button-pill" style="margin-bottom: 30px">添加学生</button>
        <table class="table table-hover" >
            <tr>
                <th width="200" style="text-align: center">学生编号</th>
                <th style="text-align: center">学生姓名</th>
                <th style="text-align: center">学生年龄</th>
                <th style="text-align: center">学生性别</th>
                <th style="text-align: center">操作</th>
            </tr>
            {{foreach from="$data" key=k item=v}}
            <tr>
                <th style="text-align: center;line-height: 300%">{{$v.sid}}</th>
                <th style="text-align: center;line-height: 300%">{{$v.name}}</th>
                <th style="text-align: center;line-height: 300%">{{$v.age}}</th>
                <th style="text-align: center;line-height: 300%">{{$v.sex}}</th>
                <th style="text-align: center">
                        <span class="button-dropdown" data-buttons="dropdown">
                            <!--<button class="button button-raised button-royal">
                                请选择操作
                            </button>-->

                            <ul class="button-dropdown-list">
                              <li class="button-dropdown-divider">
                                  <button onclick="edit(this,{{$v.sid}})" sname="{{$v.name}}" sage="{{$v.age}}" sex="{{$v.sex}}" style="width: 100%" class="button button-glow button-rounded button-highlight">编辑学生</button>
                              </li>
                              <li class="button-dropdown-divider">
                                 <button onclick="del({{$v.sid}})" style="width: 100%" class="button button-glow button-rounded button-caution">删除学生</button>
                              </li>
                            </ul>
                          </span>
                </th>
            </tr>
            {{/foreach}}
        </table>

        <!--添加班级模态框-->
        <!-- Modal -->
        <form method="post" action="" >
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" id="myModalLabel">添加班级</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="exampleInputEmail1">学生姓名</label>
                                <input type="text" name="sname" required="" value="" class="form-control" id="exampleInputEmail1" placeholder="请输入学生姓名">
                                <!--<input type="hidden" name="cid" value="">-->
                                <label for="exampleInputEmail12">学生年龄</label>
                                <input type="text" name="age" required="" value="" class="form-control" id="exampleInputEmail12" placeholder="请输入学生年龄">
                                <label for="exampleInputEmail1">请选择学生性别</label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="sex" id="inlineCheckbox1" checked="checked" value="男"> 男
                                </label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="sex" id="inlineCheckbox2" value="女"> 女
                                </label>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

        <!--编辑班级模态框-->
        <form action="index.php?m=Admin&c=Stu&a=edit&cid={{$cid}}" method="post">
            <div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" >编辑学生</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="exampleInputEmail1">学生姓名</label>
                                <input type="text" name="sname" class="form-control" placeholder="请输入班级名称">
                                <label for="exampleInputEmail1">学生年龄</label>
                                <input type="text" name="age" class="form-control" placeholder="请输入班级名称">
                                <label for="exampleInputEmail1">请选择学生性别</label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="sex" checked="checked" value="男"> 男
                                </label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="sex" value="女"> 女
                                </label>
                                <input type="hidden" name="sid" value=""/>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

        <!--删除模态框-->
        <form action="index.php?m=Admin&c=Stu&a=del&cid={{$cid}}" method="post">
            <div class="modal fade" id="del" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" >确定要删除吗？</h4>
                        </div>
                        <input type="hidden" name="sid" id="sid" value=""/>
                        <div class="modal-footer">
                            <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn btn-danger">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</body>
</html>
<script>
    function edit(obj,sid) {
        //获取旧数据
        var sname = $(obj).attr("sname");
        var age = $(obj).attr("sage");
        var sex = $(obj).attr("sex");
        $("#edit").find("input[name=sname]").val(sname);
        $("#edit").find("input[name=age]").val(age);
//        $("#edit").find("input[type=radio]").val().prop("checked",true);
        $("#edit").find("input[type=hidden]").val(sid);
        //显示模态框
        $("#edit").modal('show');
    }
    function del(sid) {
        $('#del').find("input[type=hidden]").val(sid);
        $('#del').modal("show");
    }
</script>